package com.guyaogg.gulimall.member.web;

import com.guyaogg.common.utils.R;
import com.guyaogg.gulimall.member.feign.OrderFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 顾遥
 */
@Slf4j
@Controller
public class MemberWebController {

    @Autowired
    OrderFeignService orderFeignService;

    @GetMapping("memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                  Model model) {
        // 获取到支付宝传给我们的所有数据，不推荐使用（使用异步通知
        // 查出所有当前登录用户的所有订单列表数据
        Map<String, Object> page = new HashMap<>(1);
        page.put("page", pageNum.toString());
        R r = orderFeignService.listWithItem(page);
        log.debug("订单列表:{}", r);
        model.addAttribute("orders", r);
        return "orderList";
    }
}
